﻿@page "/Home/Mall/Categroy"
@inherits YiMeiJiaService.Assembly.BaseComponent
@using YiMeiJiaLibModel.Config
@using YiMeiJiaLibModel.Business
@using YiMeiJiaApp.Pages.Components

<Headers MyPartialText="分类"></Headers>
<div class="category-container">
    <div class="weui-flex category-body">
        <div class="weui-flex__item category-left">
            @{
                var firstId = 0;
            }
            @if (_categorys != null && _categorys.Any())
            {
                var f = false;
                foreach (var item in _categorys)
                {
                    var active = "";
                    if (!f)
                    {
                        active = "active";
                        f = true;
                        firstId = item.id;
                    }
                    <a href="javascript:;" class="category-item @active " @onclick="(()=>BindCategorys(item.id))" id="category_id-@item.id">@item.name</a>
                }
                 
            }

        </div>
        <div class="weui-flex__item category-right">
            @if (_selectChild != null && _selectChild.Count > 0)
            {
                @foreach (var item in _selectChild)
                {
                    <div class="category-info" @onclick="(()=>JumpToCategoryLis(item.id))">
                        <div class="dv-img">
                            <img src="@item.imageUrl"  />
                        </div>
                        <div class="dv-name">
                            @item.name
                        </div>
                    </div>
                }
            }
          
        </div>
    </div>
</div>

<script>
 
    function selectCategory  (id){
        $(".category-item").removeClass("active");
        $(`#category_id-${id}`).addClass("active");
    }
</script>